package com.kcsj.service;

import com.kcsj.dao.PayTypeDao;
import com.kcsj.domain.PayType;
import com.kcsj.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;

/**
 * @author 傅立贤
 * 29th Nov. 2020
 */
public class PayTypeService {
    private static PayTypeDao payTypeDao = PayTypeDao.getInstance();
    private static PayTypeService payTypeService =new PayTypeService();
    private PayTypeService(){}
    public static PayTypeService getInstance(){
        return payTypeService;
    }
    /**
     * @author 傅立贤
     * @param id 查找的id
     * @return payType 查找到的付款方式
     * @throws SQLException
     */
    public PayType find(Integer id) throws SQLException {
        //获得链接
        Connection conn = JdbcHelper.getConn();
        PayType payType = payTypeDao.find(conn, id);
        JdbcHelper.close(conn);
        return payType;
    }

    public Collection<PayType> findAll() throws SQLException {
        Connection conn = JdbcHelper.getConn();
        Collection<PayType> payTypes = payTypeDao.findAll(conn);
        JdbcHelper.close(conn);
        return payTypes;
    }
}
